angular.module('ipos', [
    'ngTouch', 'ngRoute', 'ngAnimate', 'ngDialog', 'ngFileUpload',
    'baisonFilters',
    'baisonDirectives',
    'baisonService',
    'baisonDb',
    'baisonGoods',
    'baisonMember',
    'baisonReceipt',
    'baisonShop',
    'baisonUser',
    'baisonPatch',
    'baisonWeather',
    'baisonCheck',
    'baisonMessage',
    'baisonCunhuo',
    'baisonDaoGou',
    'baisonTest',
    'baisonWaitUpLoad',
    'baisonPromotion',
    'baisonSysConfig',
    'baisonReport',
    'baisonTest',
    'baisonLanguage',
    'baisonAutoPatch',
    'baisonEndDay',
    'baisonShortCut',
    'calculateSkuPrice',
    'basionThird',
    'BaisonTask'
])
        .controller('MainCtrl', MainCtrl)
        .controller('NavCtrl', NavCtrl)
        .controller('SettingNavCtrl', SettingNavCtrl)
        .controller('CunhuoNavCtrl', CunhuoNavCtrl)
        .controller('OrderNavCtrl', OrderNavCtrl)
        .controller('MemberNavCtrl', MemberNavCtrl)
        .controller('NoticeNavCtrl', NoticeNavCtrl)//add by liuwei 20170908
        .controller('MyAccountCtrl', MyAccountCtrl)
        .controller('ReportIndexCtrl', ReportIndexCtrl)
        .controller('SettingSkuPriceSynchCtrl', SettingSkuPriceSynchCtrl)
        .controller('HelpNavCtrl', HelpNavCtrl)
        .config(['$routeProvider', '$httpProvider', function ($routeProvider, $httpProvider) {
                //路由设置 =============================================
                $routeProvider.
                        when('/hello', {templateUrl: 'html/hello.html', controller: HelloCtrl}).
                        when('/index', {templateUrl: 'html/index.html', controller: IndexCtrl}).
                        when('/login', {templateUrl: 'html/login.html', controller: LoginCtrl}).
                        when('/finished/index', {templateUrl: 'html/finished/index.html', controller: FinishedCtrl}).
                        when('/progress_bar', {templateUrl: 'html/progress_bar.html', controller: ProgressBarCtrl}).
                        when('/message/index', {templateUrl: 'html/message/index.html', controller: MessageIndexCtrl}).
                        when('/daogou/index', {templateUrl: 'html/daogou/index.html', controller: DaogouIndexCtrl}).
                        when('/myaccount/personal_info', {templateUrl: 'html/myaccount/personal_info.html', controller: PersonalInfoCtrl}).
                        when('/myaccount/change_pass', {templateUrl: 'html/myaccount/change_pass.html', controller: ChangePassCtrl}).
                        when('/myaccount/attend_upload', {templateUrl: 'html/myaccount/attend_upload.html', controller: AttendUploadCtrl}).
                        when('/myaccount/performance_select', {templateUrl: 'html/myaccount/performance_select.html', controller: PerformanceSelectCtrl}).
                        when('/myaccount/dialog/shop_day_set', {templateUrl: 'html/myaccount/dialog/shop_day_set.html', controller: PerformanceSelectCtrl}).
                        when('/myaccount/scheduling', {templateUrl: 'html/myaccount/scheduling.html', controller: ScheduleCtrl}).
                        when('/setting/about', {templateUrl: 'html/setting/about.html', controller: SettingAboutCtrl}).
                        when('/setting/update_log', {templateUrl: 'html/setting/update_log.html', controller: SettingAboutCtrl}).
                        when('/setting/dev_team', {templateUrl: 'html/setting/dev_team.html', controller: SettingAboutCtrl}).
                        when('/setting/shop_set', {templateUrl: 'html/setting/shop_set.html', controller: SettingShopsetCtrl}).
                        when('/setting/check_set', {templateUrl: 'html/setting/check_set.html', controller: SettingChecksetCtrl}).
                        when('/setting/user_manage', {templateUrl: 'html/setting/user_manage.html', controller: SettingUsermanageCtrl}).
                        when('/setting/user2_manage', {templateUrl: 'html/setting/user2_manage.html', controller: SettingUsermanage2Ctrl}).
                        when('/setting/common_set', {templateUrl: 'html/setting/common_set.html', controller: SettingCommonsetCtrl}).
                        when('/setting/print_set', {templateUrl: 'html/setting/print_set.html', controller: SettingPrintsetCtrl}).
                        when('/setting/patch', {templateUrl: 'html/setting/patch.html', controller: SettingPatchCtrl}).
                        when('/setting/task_by_time', {templateUrl: 'html/setting/setting_task_by_time.html', controller: SettingTaskCtrl}).
                        when('/setting/wait_upload', {templateUrl: 'html/setting/wait_upload.html', controller: SettingWaituploadCtrl}).
                        when('/setting/chen_lie', {templateUrl: 'html/setting/chen_lie.html', controller: SettingChenLieCtrl}).
                        when('/setting/stock_synch', {templateUrl: 'html/setting/stock_synch.html', controller: SettingStockSynchCtrl}).
                        when('/setting/sku_price_synch', {templateUrl: 'html/setting/sku_price_synch.html', controller: SettingSkuPriceSynchCtrl}).
                        when('/setting/user_cash_set', {templateUrl: 'html/setting/user_cash_set.html', controller: SettingCashCtrl}).
                        when('/setting/increment_module', {templateUrl: 'html/setting/increment_module.html', controller: SettingIncrementModuleCtrl}).
                        when('/cashier/index', {templateUrl: 'html/cashier/index.html', controller: CashierIndexCtrl}).
                        when('/cashier/settle', {templateUrl: 'html/cashier/settle.html', controller: CashierSettleCtrl}).
                        when('/cashier/return/:record_code', {templateUrl: 'html/cashier/return.html', controller: CashierReturnCtrl}).
                        when('/order/xiaopiao_list/:cate', {templateUrl: 'html/order/xiaopiao/xiaopiao_list.html', controller: OrderXiaopiaoListCtrl}).
                        when('/order/xiaopiao_detail/:record_code', {templateUrl: 'html/order/xiaopiao/xiaopiao_detail.html', controller: OrderXiaopiaoDetailCtrl}).
                        when('/order/fix_list/fix', {templateUrl: 'html/order/service/fix_list.html', controller: OrderFixListCtrl}).
                        when('/order/fix_detail/:record_code', {templateUrl: 'html/order/service/fix_detail.html', controller: OrderFixDetailCtrl}).
                        when('/order/xiaopiao_list_local/:cate', {templateUrl: 'html/order/xiaopiao/xiaopiao_list.html', controller: OrderXiaopiaoListLocalCtrl}).
                        when('/order/xiaopiao_checkPending_list', {templateUrl: 'html/order/xiaopiao/xiaopiao_list_check_pending.html', controller: OrderXiaopiaoCheckPendingListCtrl}).
                        when('/order/service/depositRecord_list', {templateUrl: 'html/order/service/depositRecord_list.html', controller: OrderServiceDepositRecordList}).
                        when('/order/service/depositRecord_detail/:record_code', {templateUrl: 'html/order/service/depositRecord_detail.html', controller: OrderServiceDepositRecordDetail}).
					    when('/order/service/depositReturnRecord_list', {templateUrl: 'html/order/service/depositReturnRecord_list.html', controller: OrderServiceDepositReturnRecord}).
                        when('/order/service/depositReturnRecord_detail/:record_code', {templateUrl: 'html/order/service/depositReturnRecord_detail.html', controller: OrderServiceDepositReturnRecordDetail}).

                        when('/cunhuo/invoicing_nav', {templateUrl: 'html/cunhuo/jxcdh/invoicing_nav.html', controller: InvoicingNavCtrl}).

                        when('/cunhuo/peihuo_list', {templateUrl: 'html/cunhuo/peihuo/peihuo_list.html', controller: CunhuoPeihuoListCtrl}).
                        when('/cunhuo/peihuo_detail/:record_code', {templateUrl: 'html/cunhuo/peihuo/peihuo_detail.html', controller: CunhuoPeihuoDetailCtrl}).
                        when('/cunhuo/peihuo_add', {templateUrl: 'html/cunhuo/peihuo/peihuo_add.html', controller: CunhuoPeihuoAddCtrl}).
                        when('/cunhuo/peihuo_add_detail', {templateUrl: 'html/cunhuo/peihuo/peihuo_add_detail.html', controller: CunhuoPeihuoAddDetailCtrl}).
                        when('/cunhuo/peihuo_add_advise', {templateUrl: 'html/cunhuo/peihuo/peihuo_add_advise.html', controller: CunhuoPeihuoAddAdviseCtrl}).
                        when('/cunhuo/peihuo_add_advise_detail', {templateUrl: 'html/cunhuo/peihuo/peihuo_add_advise_detail.html', controller: CunhuoPeihuoAddAdviseDetailCtrl}).
                        when('/cunhuo/ruku', {templateUrl: 'html/cunhuo/ruku/ruku_list.html', controller: CunhuoRukuListCtrl}).
                        when('/cunhuo/ruku_detail/:record_code', {templateUrl: 'html/cunhuo/ruku/ruku_detail.html', controller: CunhuoRukuDetailCtrl}).
                        when('/cunhuo/tuiku_list', {templateUrl: 'html/cunhuo/tuiku/tuiku_list.html', controller: CunhuoTuikuListCtrl}).
                        when('/cunhuo/tuiku_detail/:record_code', {templateUrl: 'html/cunhuo/tuiku/tuiku_detail.html', controller: CunhuoTuikuDetailCtrl}).
                        when('/cunhuo/tuiku_add', {templateUrl: 'html/cunhuo/tuiku/tuiku_add.html', controller: CunhuoTuikuAddCtrl}).
                        when('/cunhuo/tuiku_add_detail', {templateUrl: 'html/cunhuo/tuiku/tuiku_add_detail.html', controller: CunhuoTuikuAddDetailCtrl}).
                        when('/cunhuo/tuiku_addAll', {templateUrl: 'html/cunhuo/tuiku/tuiku_addAll.html', controller: CunhuoTuikuAddAllCtrl}).
                        when('/cunhuo/tuiku_addAll_detail', {templateUrl: 'html/cunhuo/tuiku/tuiku_addAll_detail.html', controller: CunhuoTuikuAddAllDetailCtrl}).
                        //出库单据
                        when('/cunhuo/chuku', {templateUrl: 'html/cunhuo/chuku/chuku_list.html', controller: CunhuoChukuListCtrl}).
                        when('/cunhuo/chuku_detail/:record_code', {templateUrl: 'html/cunhuo/chuku/chuku_detail.html', controller: CunhuoChukuDetailCtrl}).
                        when('/cunhuo/diaobo_list', {templateUrl: 'html/cunhuo/diaobo/diaobo_list.html', controller: CunhuoDiaoboListCtrl}).
                        when('/cunhuo/diaobo_detail/:record_code', {templateUrl: 'html/cunhuo/diaobo/diaobo_detail.html', controller: CunhuoDiaoboDetailCtrl}).
                        when('/cunhuo/diaobo_add', {templateUrl: 'html/cunhuo/diaobo/diaobo_add.html', controller: CunhuoDiaoboAddCtrl}).
                        when('/cunhuo/diaobo_add_detail', {templateUrl: 'html/cunhuo/diaobo/diaobo_add_detail.html', controller: CunhuoDiaoboAddDetailCtrl}).
                        when('/cunhuo/diaochu_list', {templateUrl: 'html/cunhuo/diaochu/diaochu_list.html', controller: CunhuoDiaoChuListCtrl}).
                        when('/cunhuo/diaochu_detail/:record_code', {templateUrl: 'html/cunhuo/diaochu/diaochu_detail.html', controller: CunhuoDiaoChuDetailCtrl}).
                        when('/cunhuo/diaoru_list', {templateUrl: 'html/cunhuo/diaoru/diaoru_list.html', controller: CunhuoDiaoRuListCtrl}).
                        when('/cunhuo/diaoru_detail/:record_code', {templateUrl: 'html/cunhuo/diaoru/diaoru_detail.html', controller: CunhuoDiaoRuDetailCtrl}). 
                        //盘点任务单据
                        when('/cunhuo/pandianTask_list', {templateUrl: 'html/cunhuo/pandian/pandianTask_list.html', controller: CunhuoPanDianTaskListCtrl}).
//                      //盘点任务单详细
                        when('/cunhuo/pandianTask_detail/:record_code', {templateUrl: 'html/cunhuo/pandian/pandianTask_detail.html', controller: CunhuoPanDianTaskDetailCtrl}).
                        when('/cunhuo/pandian_list', {templateUrl: 'html/cunhuo/pandian/pandian_list.html', controller: CunhuoPanDianListCtrl}).
                        when('/cunhuo/pandian_detail/:record_code', {templateUrl: 'html/cunhuo/pandian/pandian_detail.html', controller: CunhuoPanDianDetailCtrl}).
                        when('/cunhuo/pandian_add', {templateUrl: 'html/cunhuo/pandian/pandian_add.html', controller: CunhuoPanDianAddCtrl}).
                        when('/cunhuo/pandian_add_detail', {templateUrl: 'html/cunhuo/pandian/pandian_add_detail.html', controller: CunhuoPanDianAddDetailCtrl}).
                        when('/cunhuo/adjust_list', {templateUrl: 'html/cunhuo/adjust/adjust_list.html', controller: CunhuoAdjustListCtrl}).
                        when('/cunhuo/adjust_detail/:record_code', {templateUrl: 'html/cunhuo/adjust/adjust_detail.html', controller: CunhuoAdjustDetailCtrl}).
                        when('/cunhuo/sale_list', {templateUrl: 'html/cunhuo/finished/sale.html', controller: FinishedSaleCtrl}).
                        when('/cunhuo/sale_detail/:record_code', {templateUrl: 'html/cunhuo/finished/sale_detail.html', controller: FinishedSaleCtrl}).
                        when('/cunhuo/return_list', {templateUrl: 'html/cunhuo/finished/return.html', controller: FinishedReturnCtrl}).
                        when('/report/spkc', {templateUrl: 'html/report/spkc.html', controller: SpkcCtrl}).
                        when('/report/kczfx', {templateUrl: 'html/report/kczfx.html', controller: KczfxCtrl}).
                        when('/report/jxcfx', {templateUrl: 'html/report/jxcfx.html', controller: JxcfxCtrl}).
                        when('/report/arfx', {templateUrl: 'html/report/arfx.html', controller: ArfxCtrl}).
                        when('/report/rxph', {templateUrl: 'html/report/rxph.html', controller: RxphCtrl}).
                        when('/report/dgyj', {templateUrl: 'html/report/dgyj.html', controller: DgyjCtrl}).
                        when('/report/lsfx', {templateUrl: 'html/report/lsfx.html', controller: LsfxCtrl}).
                        when('/report/zfgc', {templateUrl: 'html/report/zfgc.html', controller: ZfgcCtrl}).
                        when('/report/more', {templateUrl: 'html/report/more.html', controller: MoreReportCtrl}).
                        when('/promotion/index', {templateUrl: 'html/promotion/index.html', controller: PromotionIndexCtrl}).
                        when('/member/list/induced_member', {templateUrl: 'html/member/list/induced_member.html', controller: MemberInducedMemberCtrl}).
                        when('/member/list/birthday_member', {templateUrl: 'html/member/list/birthday_member.html', controller: MemberBirthdayMemberCtrl}).
                        when('/member/list/recent_member', {templateUrl: 'html/member/list/recent_member.html', controller: MemberRecentMemberCtrl}).
                        when('/member/list/point_member', {templateUrl: 'html/member/list/point_member.html', controller: MemberPointMaturityCtrl}).
                        //add by liuwei on 2017.08.25 增加会员扫码
						when('/member/member_detail/:vip_code', {templateUrl: 'html/member/member_detail.html', controller: MemberDetailCtrl}).
                        when('/member/add', {templateUrl: 'html/member/add.html', controller: MemberAddCtrl}).
						//add by liuwei on 2017.04.19 增加廉政
						when('/notice/qywh', {templateUrl: 'html/message/notice/qywh.html', controller: QywhIndexCtrl}).
                        when('/notice/lczd', {templateUrl: 'html/message/notice/lczd.html', controller: LczdIndexCtrl}).
                        when('/notice/lz',   {templateUrl: 'html/message/notice/lz.html',   controller: LzIndexCtrl}).
						when('/notice/chakan',   {templateUrl: 'html/message/notice/chakan.html',   controller: ChakanIndexCtrl}).
						//when('/lz',   {templateUrl: 'html/message/lz.html',   controller: LzIndexCtrl}).
						//add by liuwei on 2017.08.25
						when('/oa', {templateUrl: 'html/message/oa.html', controller: OaIndexCtrl}).
                        when('/test/index', {templateUrl: 'html/test/index.html', controller: TestIndexCtrl}).
                        //when('/test/face', {templateUrl: 'html/test/face.html', controller: TestFaceCtrl}).
                        // when('/help/index', {templateUrl: 'html/help/index.html', controller: HelpIndexCtrl}).
                        when('/help/shortcut', {templateUrl: 'html/help/shortcut.html', controller: HelpShortcutCtrl}).
                        when('/help/achievement', {templateUrl: 'html/help/achievement.html', controller: HelpAchievementCtrl}).
                        otherwise({redirectTo: '/hello'});

                //mePageLoadingProvider.autoPageLoading = false;

                //HTTP异步设置 =============================================
                $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
                /**
                 * The workhorse; converts an object to x-www-form-urlencoded serialization.
                 * @param {Object} obj
                 * @return {String}
                 */
                var param = function (obj) {
                    var query = '', name, value, fullSubName, subName, subValue, innerObj, i;
                    for (name in obj) {
                        value = obj[name];
                        if (value instanceof Array) {
                            for (i = 0; i < value.length; ++i) {
                                subValue = value[i];
                                fullSubName = name + '[' + i + ']';
                                innerObj = {};
                                innerObj[fullSubName] = subValue;
                                query += param(innerObj) + '&';
                            }
                        } else if (value instanceof Object) {
                            for (subName in value) {
                                subValue = value[subName];
                                fullSubName = name + '[' + subName + ']';
                                innerObj = {};
                                innerObj[fullSubName] = subValue;
                                query += param(innerObj) + '&';
                            }
                        } else if (value !== undefined && value !== null)
                            query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
                    }
                    return query.length ? query.substr(0, query.length - 1) : query;
                };

                // Override $http service's default transformRequest
                $httpProvider.defaults.transformRequest = [function (data) {
                        return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
                    }];
            }
        ])
        ;
